<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>炫酷的组件</title>
</head>
<body>
<div id="app">
    <ol>
        <todo-item
                v-for="item in arrayList"
                v-bind:todo="item"
                :key="item.id"></todo-item>
    </ol>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
    /*定义vue组件*/
    Vue.component('todo-item',{
        //自定义属性 取名todo
        props:['todo'],
        template: '<li>{{todo.text}}</li>'
    })

    var vm = new Vue({
        el:"#app",
        data:{
            arrayList:[{id:0,text:'tomato'},
                {id:1,text:'nodes'},
                {id:2,text:'rice'}]
        }
    })
</script>
</body>
</html>